clear all

use "hetdata.dta"


*changes in partisan consistency in the control
tab diff3recode if treat==0

*changes in partisan consistency in the treatment condition
tab diff3recode if treat==1

*treatment effect on partisan consistency
prtest diffpos, by(treat)

*treatment effect on stable attitude
prtest diffnull, by(treat)

*treatment effect on partisan inconsistency
prtest diffneg, by(treat)

*distribution of pretreatment dv
tab predv

*treatment effect on partisan consistency (any movement) among those initially opposed to party's view
prtest diffpos if preconsistent==-1, by(treat)

*change from opposing party to midpoint
prtest opptomid, by(treat)

*change from opposing party to favoring
prtest opptofav, by(treat)



*figure 6
gen x=.
replace x=-1 in 1
replace x=0 in 2
replace x=1 in 3
gen eff=.
gen lo=.
gen hi=.

prtest diffpos, by(treat)
replace eff=r(P_diff) in 1
replace lo=r(lb_diff) in 1
replace hi=r(ub_diff) in 1
prtest diffnull, by(treat)
replace eff=r(P_diff) in 2
replace lo=r(lb_diff) in 2
replace hi=r(ub_diff) in 2
prtest diffneg, by(treat)
replace eff=r(P_diff) in 3
replace lo=r(lb_diff) in 3
replace hi=r(ub_diff) in 3

replace eff=-1*eff
replace lo=-1*lo
replace hi=-1*hi

twoway (scatter eff x) (rcap lo hi x, lcolor(black) xtitle("") ///
	xlab(-1 `""More" "Consistent""' 0 `""No" "Change""' 1 `""Less" "Consistent""') ///
	xsc(range(-1.5 1.5) titlegap(2)) yline(0) ytitle("Change in Proportions") ///
	legend(off) subtitle("Treatment - Control") saving(pidchange.gph, replace))

prtest diffpos, by(treat)
replace eff=r(P1) in 1
replace lo=r(lb1) in 1
replace hi=r(ub1) in 1
prtest diffnull, by(treat)
replace eff=r(P1) in 2
replace lo=r(lb1) in 2
replace hi=r(ub1) in 2
prtest diffneg, by(treat)
replace eff=r(P1) in 3
replace lo=r(lb1) in 3
replace hi=r(ub1) in 3

twoway (bar eff x, color(gs12)) (rcap lo hi x, lcolor(black) xtitle("") ///
	xlab(-1 `""More" "Consistent""' 0 `""No" "Change""' 1 `""Less" "Consistent""') ///
	xsc(range(-1.5 1.5) titlegap(2)) yline(0) ylab(0(.25)1) ytitle("Proportion") ///
	legend(off) subtitle("Control") saving(pidcontrol.gph, replace))

	
prtest diffpos, by(treat)
replace eff=r(P2) in 1
replace lo=r(lb2) in 1
replace hi=r(ub2) in 1
prtest diffnull, by(treat)
replace eff=r(P2) in 2
replace lo=r(lb2) in 2
replace hi=r(ub2) in 2
prtest diffneg, by(treat)
replace eff=r(P2) in 3
replace lo=r(lb2) in 3
replace hi=r(ub2) in 3

twoway (bar eff x, color(gs12)) (rcap lo hi x, lcolor(black) xtitle("") ///
	xlab(-1 `""More" "Consistent""' 0 `""No" "Change""' 1 `""Less" "Consistent""') ///
	xsc(range(-1.5 1.5) titlegap(2)) yline(0) ylab(0(.25)1) ytitle("Proportion") ///
	legend(off) subtitle("Treatment") saving(pidtreat.gph, replace))

graph combine pidcontrol.gph pidtreat.gph pidchange.gph, rows(1)
	
	
